import java.util.PriorityQueue;

public class test1 {
    //力扣  2208.将数组和减半的最小操作数
    public int halveArray(int[] nums) {
        //创建一个大根堆
        PriorityQueue<Double> heap = new PriorityQueue<>((a, b)->b.compareTo(a));
        double sum = 0;
        //数组中的数据放到堆里面并算出数组和
        for(int n:nums){
            heap.offer((double)n);
            sum+=n;
        }
        //数组和减半
        sum/=2.0;
        int count = 0;
        while(sum>0){
            double t = heap.poll()/2.0;
            heap.offer(t);
            sum-=t;
            count++;
        }
        return count;
    }
}
